﻿@using Discussion.Core.Models
@inject Discussion.Core.Models.SiteSettings SiteSettings
@{
    ViewData["Title"] = "创建新主题";
}

@if (SiteSettings.CanCreateNewTopics())
{
    <div class="row clearfix">
        <h3>创建新话题</h3>
        <div class="topic-title-container">
            <input id="new-topic-title" type="text" placeholder="标题" autofocus maxlength="120"/>
        </div>
        <div class="topic-content-container">
            <div id="content-editor"></div>
        </div>
    </div>
    <div class="row topic-submit-section clearfix">
        <button id="submit-create" class="btn btn-default submit-create-btn">创建</button>
        <div id="topic-type-dropdown" class="dropdown topic-type-dropdown">
            <div class="dropdown-toggle topic-type-btn" data-toggle="dropdown" aria-haspopup="true">
                <span class="selected-type">话题类别</span>
                <span class="caret"></span>
            </div>
            <ul class="dropdown-menu">
                @foreach (var item in Html.GetEnumSelectList<TopicType>())
                {
                    <li class="topic-type-item"><a href="javascript:;" attr-value="@item.Value">@item.Text</a></li>
                }
            </ul>
        </div>
    </div>
}
else
{
    <div class="row clearfix">
        <h3>当前暂不允许创建新的话题，请稍后再来。</h3>
    </div>
}

@section Tail{
    <script>
        window.createTopicUrl = "@Url.Action("CreateTopic")";
        window.uploadUrl = '@Url.Action("UploadFile", "Common", new {category = "topic"})';
        window.DiscussionApp.mdeditor.setupEditor();
    </script>
}